<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
    <head>
        <title></title>
        <meta charset="utf-8">
        <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="css/ui-btn.css">
    <link rel="stylesheet" href="css/ui-input.css">
        <link rel="stylesheet" href="css/ui-base.css">
        <link rel="stylesheet" href="css/ui-box.css">
        <link rel="stylesheet" href="css/ui-color.css">
		<link rel="stylesheet" href="css/ui-res.css">
        <script src="js/zy_control.js">
        </script>
        <script src="js/zy_click.js">
        </script>
		<script src="js/json.js"></script>
        <script>
        	
			
				function changesex(id)

					{
 						if(id==1)

   									{document.getElementById("s1").src= "css/image/xzb.png";}


  								 else if(id==2){


       								 document.getElementById("s1").src= "css/image/xzg.png";
												 }
					}
			
			
        
        </script>
		<style>
			
			
		</style>
		
		
		
		
		
    </head>
    <body class="um-vp c-wh" ontouchstart>
        <div id="page_0" class="up ub ub-ver" tabindex="0">
            <!--header开始-->
            <div id="header" class="uh c-bla  t-wh">
                <h1 class="ut ulev0 ut-s tx-c" tabindex="0">注册</h1>
				<!--返回按钮开始-->
		  <div ontouchstart="zy_touch('btn-act')" onclick="returnlogin()" class="btn uba b-bla uinn btn-l c-bla  uc-a t-wh">返回</div>
			<!--按钮结束-->
			
			<!--按钮开始-->
			<div ontouchstart="zy_touch('btn-act')" onclick="register()" class="btn uba b-bla uinn btn-r c-bla  uc-a t-wh">确定</div>
			<!--按钮结束-->
			
            </div>
		
			
            <!--header结束-->
			
			
			<!--content开始-->
            <div id="content" class="ub-f1 tx-l t-bla " style="padding:1em 0.4em 1em 0.4em">
              
			  <!--块容器开始-->
				<div class="ub ub-ver uba uc-a1 t-wh " style="box-shadow:1px 1px 1px 1px;border:0.08em solid #ABABAB">	
 					<div class="ubb b-gra  c-m2 uinn uc-t1" >
 						<!--文本开始-->
							<div class="ub t-bla ulab">  
								<div class="uinn ulim">昵称</div> 
 									<div class="ub-f1 c-wh  uinput uinn4">  
 										<input  id="nick" placeholder="2-10个汉字中英、数字、下划线"  type="text" class="uc-n">   
 							 		</div>
							</div>
						<!--文本结束-->
					</div>
					
					
	 					<div class="ubb b-gra c-m2 uinn " >

						<!--文本开始-->
							<div class="ub t-bla ulab">  
								<div class="uinn ulim">邮箱</div> 
 									<div class="ub-f1 c-wh  uinput uinn4">  
 										<input id="email" placeholder="输入正确邮箱"  type="text" class="uc-n">   
 							 		</div>
							</div>
						<!--文本结束-->




						</div>	
						
						
							 <div class=" c-m2 uinn uc-b1"  >
							 	
						<!--文本开始-->
							<div class="ub t-bla ulab">  
								<div class="uinn ulim">密码</div> 
 									<div class="ub-f1 c-wh  uinput uinn4">  
 										<input id="pswd" placeholder="6-15个字母、数字、符号、区别大小写"  type="text" class="uc-n">   
 							 		</div>
							</div>
						<!--文本结束-->

							</div> 
			
								
								
								
		<!--块容器结束-->
			  
					<!--块容器开始性别-->
			
				
					
				</div></a>
				<div style="text-align:center;margin-top:1.5em">
					<img id=s1 src="css/image/xzb.png" style="width:450px;height:60px" usemap="#changesex">
						<map name="changesex">
							<area shape="rectangle" coords="0,0,225,60" href="javascript:;" onclick="changesex(1)"></area>
							
							<area shape="rectangle" coords="225,0,450,60" href="javascript:;" onclick="changesex(2)"></area>
							
							
							
						</map>
				
				
				</div>
			</div>
					<!--块容器结束-->
			  
			  
			  
			    
            </div>
            <!--content结束-->
        </div>
    </body>
    <script>
    	zy_init();
		
		
		
		function returnlogin(){
	uexWindow.open("dymlogin",0,"dymlogin.html",1,"","",0,250);
}
function reg(){
	uexWindow.open("indexs",0,"indexs.html",1,"","",0,250);
}
		
	
	function register(){
		var httpID=997;
		var txtnick=$$("nick").value;
		var txtemail=$$("email").value;
		var txtpswd=$$("pswd").value;
		var emailreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
		var pswdreg=/[a-zA-Z0-9]{6,16}/;
		var nickreg= /^(\w+)|([\u0391-\uFFE5]+)$/;
		if(txtnick==null||txtemail==null||txtpswd==null)
		{
			uexWindow.toast(1,5,"密码，email，用户名不能为空",1000);
		}
		else if(!emailreg.test(txtemail)){
			uexWindow.toast(1,5,"email格式不正确",1000);
		}
		else if(!pswdreg.test(txtpswd)){
			uexWindow.toast(1,5,"密码格式不正确",1000);
		}
		else if(!nickreg.test(txtemail)){
			uexWindow.toast(1,5,"用户名格式不正确",1000);
		}
		else{
			uexXmlHttpMgr.onData=function(inOpCode,inStatus,inResult){
				if(inStatus=1){
					var json=eval("(" + inResult + ")");
					if(json["success"]){
						window.localStorage.setItem("email",txtemail);
						window.localStorage.setItem("password",txtpswd);
						window.localStorage.setItem("username",txtnick);
						uexWindow.toast(1,5,"注册成功,登入中",0);
						autoLogin();
					}
					else{
						uexWindow.toast(1,5,json["message"],1000);
					}
				}
			}
			uexXmlHttpMgr.open(httpID,'get','http://192.168.123.31/fish/api/public/register?uname='+txtnick+'&password='+txtpswd+'&email='+txtemail,3000);
			
			uexXmlHttpMgr.send(httpID);
		}
	}
	/**
	 * 注册后自动登录
	 */
	
	function autoLogin(){
		var httpID=1011;
		if(window.localStorage["username"]!=null&&window.localStorage["password"]!=null){
			uexXmlHttpMgr.onData=function(inOpCode,inStatus,inResult){
				if(inStatus=1){
					var json=eval("(" + inResult + ")");
					if(json["success"])
					{
						uexWindow.closeToast();
						window.localStorage.setItem("session_id",json["session_id"]);
						uexWindow.open("indexs",0,"indexs.html",1,"","",0,350);
					}
					else{
						uexWindow.toast(1,5,json["message"],500);
					}
				}
			}
			
			uexXmlHttpMgr.open(httpID,'get','http://192.168.123.31/fish/api/public/login?username='+window.localStorage["username"]+'&password='+window.localStorage["password"],3000);
			//uexWindow.setPostData(httpID,"username",window.localStorage["username"]);
			//uexWindow.setPostData(httpID,"password",window.localStorage["password"]);
			uexXmlHttpMgr.send(httpID);
		}
		
	}
	
</script> 	
	


    </script>
</html>
